<template>
	<div class="bar button ml20 mr20 mt15 fs18">
		<div class="clearfix" v-show="!userInfo.userPhone">
			<router-link class="fl" to="/login">
				<button class="left">登录</button>
			</router-link>
			<router-link class="fr" to="/register">
				<button class="right">注册</button>
			</router-link>
		</div>
		<div class="clearfix" v-show="userInfo.userPhone">
			<a href="javascript:;" class="fl">
				<button class="left" @click="getCash">
						<!-- <button class="left" > -->
					<img :src="topup" height="18" alt="">
					<span class="ml5">提现</span>
				</button>
			</a>
			<a class="fr" href="javascript:;" @click.stop="getTopupAuth">
				<button class="right">
					<img :src="withdraw" height="18" alt="">
					<span class="ml5">充值</span>
				</button>
			</a>
		</div>
	</div>
</template>
<script>
	export default {
		name: 'bar',
		data () {
			return {
				topup: "./static/imgs/topup.svg",
				withdraw: "./static/imgs/withdraw.svg",
			}
		},
		props: {
			userInfo: {
				type: Object,
				required: true,
				default: {},
			},
			topupAuth: {
				type: Object,
				required: true,
				default: {},
			}
		},
		mounted() {
			
		},
		methods: {
			getCash() {
				if (this.topupAuth == {}) {
					this.$router.push({
						path: "/login"
					});
				} else if (this.topupAuth.cardState) {
					this.$router.push({
						path: "/account/withdraw"
					});
				} else {
					MessageBox.confirm("", {
						title: "提现",
						message: "为了您的资金安全，请前去绑卡",
						confirmButtonText: "去绑定",
						confirmButtonClass: "red"
					}).then(
						action => {
							this.$router.push({
								path: "/account/bindbank"
							});
						},
						() => { }
					);
				}
			},
			getTopupAuth() {
				if (Object.keys(this.topupAuth).length === 0) {
					this.$router.push({
						path: "/login",
					});
				} else if (this.topupAuth.identify === 1 && !this.topupAuth.cardState) {
					MessageBox.confirm("", {
						title: "充值",
						message: "为了您的资金安全，请前去绑卡",
						confirmButtonText: "去绑定",
						confirmButtonClass: "red"
					}).then(() => {
						this.$router.push({
							path: "/account/bindbank",
						});
					});
				} else {
					window.location.href = "./account/paySelect.html";
				}
			}
		},
	}
</script>
<style scoped lang='scss'>
.button div a {
		width: 50%;
	}

	button {
		border: 0 none;
		line-height: rem(35px);
		border-radius: rem(4px);
		font-size: rem(16px);
		color: #fff;
		display: block;
		width: 90%;
	}

	button.left {
		background: linear-gradient(90deg, #ffba00, #ff9000);
	}

	button.right {
		background: linear-gradient(90deg, #ff6c47, #ff3c4b);
		float: right;
	}
</style>